namespace Dida
{
	public class KeyframedValue<T> : IAniValue<T>
	{
		LinearKeyframes<T> keyframes;

		bool playing;
		LinearKeyframes<T>.Iterator iterator;
		T curValue;

		public KeyframedValue(LinearKeyframes<T> keyframes,float initialPosition,
			bool initiallyPlaying)
		{
			this.keyframes = keyframes;
			this.playing = initiallyPlaying;

			iterator = keyframes.GetIterator(initialPosition);
			curValue = iterator.CurValue;
		}

		public T CurrentValue
		{
			get 
			{
				return curValue;
			}
		}

		public void Start()
		{
			playing = true;
		}

		public void Update(float timeDelta)
		{
			iterator.MoveForward(timeDelta);
			curValue = iterator.CurValue;
		}
	}

	[Dxml.DidaObject]
	public class KeyframedVector3D : KeyframedValue<Vector3D>
	{
		[Dxml.AutoXmlConstructor]
		public KeyframedVector3D(Vector3DLinearKeyframes keyframes,float initialPosition,bool initiallyPlaying)
			: base(keyframes,initialPosition,initiallyPlaying)
		{
		}
	}

	[Dxml.DidaObject]
	public class KeyframedQuaternion : KeyframedValue<Quaternion>
	{
		[Dxml.AutoXmlConstructor]
		public KeyframedQuaternion(QuaternionLinearKeyframes keyframes, float initialPosition, bool initiallyPlaying)
			: base(keyframes, initialPosition, initiallyPlaying)
		{
		}
	}
}